<?php
//作者：jinfan
//时间：2015-03-24 14:37:00
//说明：数据库操作工具类
//
//
//

class DB
{
	var $conn;
	//初始化连接
	function DB()
	{
		$this->conn =
		 mysql_connect(DB_IP, DB_USERNAME,
                        DB_PASSWORD);
		 
	}
	//查询
	function query($sql)
	{
		$rs=array();
		mysql_query("SET CHARACTER SET utf8");
		mysql_query("set names utf8");
		mysql_select_db(DB_DATABASE);
		$result = mysql_query($sql,$this->conn);
		while ($row=mysql_fetch_assoc($result)) {
			$rs[]=$row;

		}
		return $rs;

	}
	

	//查询
	function getOne($sql)
	{
		mysql_query("SET CHARACTER SET utf8");
		mysql_query("set names utf8");
		mysql_select_db(DB_DATABASE);
		$result = mysql_query($sql,$this->conn);		
		return mysql_fetch_assoc($result);

	}
	//更新
	function update($sql)
	{
		mysql_query("set names utf8");
		mysql_select_db(DB_DATABASE,$this->conn);
		$result = mysql_query($sql);
		return $result;
		
	}
	//关闭连接
	function close()
	{
		mysql_close($this->conn);
	}
	
}

?>